package com.pkk.penguin.frame.know.java.driven.condition;

import com.pkk.penguin.frame.know.java.driven.condition.importbean.importbeandefinition.MyImportBeanDefinition;
import com.pkk.penguin.frame.know.java.driven.condition.importbean.importselector.ImportSelectorBeanOne;
import com.pkk.penguin.frame.know.java.driven.condition.importbean.importselector.MyImportSelector;
import com.pkk.penguin.frame.know.java.driven.condition.importbean.simple.ImportBean;
import java.util.Arrays;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * @description: 条件测试类
 * @author: peikunkun
 * @create: 2020-07-31 14:51
 **/
@Slf4j
@ComponentScan(value = "com.pkk.penguin.frame.know.java.driven.condition")
@Configuration
@Import({ImportBean.class, MyImportSelector.class, MyImportBeanDefinition.class})
public class ConditionTests {


  @Test
  public void Administrator_34_20200730180232_Condition() {
    System.out.println("欢迎使用单元测试方法【Administrator_34()_20200730180232】");
    System.out.println("此方法测试描述：【@Import(ImportBean.class)手动导入bean到容器中】");
    this.print();


  }

  void print() {
    AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(
        ConditionTests.class);
    final String[] beanDefinitionNames = annotationConfigApplicationContext.getBeanDefinitionNames();
    System.out.println("--------------------------------");
    Arrays.stream(beanDefinitionNames).forEach(s -> System.out.println(s));
    final ImportSelectorBeanOne bean = annotationConfigApplicationContext.getBean(ImportSelectorBeanOne.class);
    System.out.println(bean.readme());
  }

}
